function selectCheckbox(){
  var object = document.getElementsByName("checkbox2");
  var checkedAll=true;
  if(!object[0].checked){
     checkedAll=false;
  }
  var  myobject= document.all.tags("input");
  var mynum = myobject.length;
  for(i=0;i<mynum;i++){
  if(myobject[i].type== "checkbox"){
     myobject[i].checked=checkedAll;
  }
  }
}
function checkNum(obj){
	var Str = obj.value;
	if(!isNumStr(Str)){
		alert('请输入正确的数字！');
		obj.focus();
	}
}
/*********************************************************************************/
/**	函数：boolean isNumStr(String Str)					**/
/**	作者：余昌坤								**/
/**	日期：2002-07-17							**/
/**	功能：判断某个字符串是否为数字字符串					**/
/*********************************************************************************/
function isNumStr(Str){
	var RNumStr="[^0-9.]"
    	var NumRule = new RegExp(RNumStr)
	if(Str==null || Str=="")
		return true
	if(Str.search(NumRule)!=-1)
		return false
	else
		return true
}

function checkDate(obj){
	var Str = obj.value;
	if(!isDate(Str)){
		alert('请输入正确的日期！');
		obj.focus();
	}
}

function isDate(str){
 if(str=='') return true;
   var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
   if(r==null)return false;
   var d= new Date(r[1], r[3]-1, r[4]);
   return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
}

function fnRemoveBlank(str)  //trim Blank
{
 return str.replace(/^ + /,"").replace(/ + $/,"")
}

function selectAllCheckbox(){
	var curForm = document.forms[0];
	for(var i=0;i<curForm.elements.length;i++){
		var ctrl = curForm.elements[i];
		if(ctrl.type=='checkbox'){
			ctrl.checked = true;
		}
	}
}

function cancelAllCheckbox(){
	var curForm = document.forms[0];
	for(var i=0;i<curForm.elements.length;i++){
		var ctrl = curForm.elements[i];
		if(ctrl.type=='checkbox'){
			ctrl.checked = false;
		}
	}
}

function openWindow(this_url,w_width,w_height,w_name,w_top,w_left) {
	if (!w_top)
		w_top = (screen.height - w_height)/2;
	if (!w_left)
		w_left = (screen.width - w_width)/2;
			
	w_param = "top=#t#,left=#l#,width=#w#,height=#h#,channelmode = no,directories=no,resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,titlebar=no,toolbar=no";
	w_param = w_param.replace("#h#",w_height);
	w_param = w_param.replace("#w#",w_width);
	w_param = w_param.replace("#t#",w_top);
	w_param = w_param.replace("#l#",w_left);
    if (w_name)
		childWindow = window.open(this_url,w_name,w_param);
	else
		childWindow = window.open(this_url,'',w_param);
	//childWindow.focus();
	//return childWindow;
}
